package com.hh.bss.common.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.core.MethodParameter;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.hh.bss.util.StringHelper;

public class CommContextInterceptor extends HandlerInterceptorAdapter {   
    
	   @Override  
	    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {   
//	      String contentType = response.getContentType();   
//	      if (StringUtils.isEmptyOrNullByTrim(contentType)) {   
//	          response.setContentType("text/html;charset=UTF-8");   
//	      }   
//		   HandlerMethod handlerMethod = (HandlerMethod) handler;  
//		       for (MethodParameter methodParameter : handlerMethod.getMethodParameters()) {  
//		           methodParameter.getParameterName();  
//		           //怎么获取参数值？获取username 和password   
//		       }  

		   System.out.println("CommContextInterceptor............."+handler.getClass().getName());
	        return true;   
	    }   
	  
	    @Override  
	    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {   
//	        if (null != modelAndView && null == modelAndView.getModel().get(ConstantsV2.CONTEXT_PATH)) {   
//	                modelAndView.addObject(ConstantsV2.CONTEXT_PATH, request.getContextPath());   
//	        }   
	        String contentType = response.getContentType();  	       
//	        if ( StringHelper.isEmpty(contentType)) {   
//	            response.setContentType("text/html;charset=UTF-8");   
//	        }   
	        response.setContentType("text/html;charset=UTF-8");
	    }   
	  
	}  

